<template>
  <div class="style-page">
    <div class="head-page-title">{{ showComponentData.title }}</div>
    <div class="line"></div>
    <div class="head-title">组件样式</div>

    <div class="component-style">
      <el-form :model="form">
        <el-form-item label="内容布局：">
          <el-radio-group v-model="showComponentData.layout">
            <el-radio value="row-2">一行两个</el-radio>
            <el-radio value="row-3">一行三个</el-radio>
            <el-radio value="left-1-right-2">左一右二</el-radio>
            <el-radio value="top-1-bottom-2">上一下二</el-radio>
            <el-radio value="left-2-right-1">左二右一</el-radio>
            <el-radio value="top-2-bottom-1">上二下一</el-radio>
            <el-radio value="top-2-bottom-2">上二下二</el-radio>
            <el-radio value="top-2-bottom-3">上二下三</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="内容间距：">
          <div class="flex">
            <el-slider
              style="width: 70%"
              v-model="showComponentData.itemStyle.gap"
              :min="1"
              :max="30"
            />
            <el-input
              style="width: 30%; margin-left: 20px"
              type="number"
              v-model.number="showComponentData.itemStyle.gap"
              :min="1"
              :max="30"
            >
              <template #append>px</template>
            </el-input>
          </div>
        </el-form-item>
        <el-form-item label="内容圆角：">
          <div class="flex">
            <el-slider
              style="width: 70%"
              v-model="showComponentData.itemStyle.borderRadius"
              :min="0"
              :max="50"
            />
            <el-input
              style="width: 30%; margin-left: 20px"
              type="number"
              v-model.number="showComponentData.itemStyle.borderRadius"
              :min="0"
              :max="50"
            >
              <template #append>px</template>
            </el-input>
          </div>
        </el-form-item>
        <div class="cube-template">
          <template v-if="showComponentData.layout === 'row-2'">
            <div class="cube-style cube-style-row-2">
              <div
                class="cube-item"
                @click="handleClickIndex(0)"
                :class="{ active: clickDivIndex === 0 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[0]"
                  :src="showComponentData.default_sub_list[0]"
                  class="itemImg"
                />
                <p class="tip" v-else>宽度375px</p>
              </div>
              <div
                class="cube-item"
                @click="handleClickIndex(1)"
                :class="{ active: clickDivIndex === 1 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[1]"
                  :src="showComponentData.default_sub_list[1]"
                  class="itemImg"
                />
                <p class="tip" v-else>宽度375px</p>
              </div>
            </div>
          </template>

          <template v-if="showComponentData.layout === 'row-3'">
            <div class="cube-style cube-style-row-3">
              <div
                class="cube-item"
                @click="handleClickIndex(0)"
                :class="{ active: clickDivIndex === 0 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[0]"
                  :src="showComponentData.default_sub_list[0]"
                  class="itemImg"
                />
                <p class="tip" v-else>宽度250px</p>
              </div>
              <div
                class="cube-item"
                @click="handleClickIndex(1)"
                :class="{ active: clickDivIndex === 1 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[1]"
                  :src="showComponentData.default_sub_list[1]"
                  class="itemImg"
                />
                <p class="tip" v-else>宽度250px</p>
              </div>
              <div
                class="cube-item"
                @click="handleClickIndex(2)"
                :class="{ active: clickDivIndex === 2 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[2]"
                  :src="showComponentData.default_sub_list[2]"
                  class="itemImg"
                />
                <p class="tip" v-else>宽度250px</p>
              </div>
            </div>
          </template>

          <template v-if="showComponentData.layout === 'left-1-right-2'">
            <div class="cube-style cube-style-left-1-right-2">
              <div
                class="cube-item left"
                @click="handleClickIndex(0)"
                :class="{ active: clickDivIndex === 0 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[0]"
                  :src="showComponentData.default_sub_list[0]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x750像素或同等比例</p>
              </div>
              <div
                class="cube-item right-top"
                @click="handleClickIndex(1)"
                :class="{ active: clickDivIndex === 1 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[1]"
                  :src="showComponentData.default_sub_list[1]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
              <div
                class="cube-item right-bottom"
                @click="handleClickIndex(2)"
                :class="{ active: clickDivIndex === 2 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[2]"
                  :src="showComponentData.default_sub_list[2]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
            </div>
          </template>

          <template v-if="showComponentData.layout === 'top-1-bottom-2'">
            <div class="cube-style cube-style-top-1-bottom-2">
              <div
                class="cube-item top"
                @click="handleClickIndex(0)"
                :class="{ active: clickDivIndex === 0 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[0]"
                  :src="showComponentData.default_sub_list[0]"
                  class="itemImg"
                />
                <p class="tip" v-else>750x375像素或同等比例</p>
              </div>
              <div
                class="cube-item bottom-left"
                @click="handleClickIndex(1)"
                :class="{ active: clickDivIndex === 1 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[1]"
                  :src="showComponentData.default_sub_list[1]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
              <div
                class="cube-item bottom-right"
                @click="handleClickIndex(2)"
                :class="{ active: clickDivIndex === 2 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[2]"
                  :src="showComponentData.default_sub_list[2]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
            </div>
          </template>

          <template v-if="showComponentData.layout === 'left-2-right-1'">
            <div class="cube-style cube-style-left-2-right-1">
              <div
                class="cube-item left-top"
                @click="handleClickIndex(0)"
                :class="{ active: clickDivIndex === 0 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[0]"
                  :src="showComponentData.default_sub_list[0]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x750像素或同等比例</p>
              </div>
              <div
                class="cube-item left-bottom"
                @click="handleClickIndex(1)"
                :class="{ active: clickDivIndex === 1 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[1]"
                  :src="showComponentData.default_sub_list[1]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
              <div
                class="cube-item right"
                @click="handleClickIndex(2)"
                :class="{ active: clickDivIndex === 2 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[2]"
                  :src="showComponentData.default_sub_list[2]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
            </div>
          </template>

          <template v-if="showComponentData.layout === 'top-2-bottom-1'">
            <div class="cube-style cube-style-top-2-bottom-1">
              <div
                class="cube-item top-left"
                @click="handleClickIndex(0)"
                :class="{ active: clickDivIndex === 0 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[0]"
                  :src="showComponentData.default_sub_list[0]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
              <div
                class="cube-item top-right"
                @click="handleClickIndex(1)"
                :class="{ active: clickDivIndex === 1 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[1]"
                  :src="showComponentData.default_sub_list[1]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
              <div
                class="cube-item bottom"
                @click="handleClickIndex(2)"
                :class="{ active: clickDivIndex === 2 }"
              >
                <img
                  v-if="showComponentData.default_sub_list[2]"
                  :src="showComponentData.default_sub_list[2]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x750像素或同等比例</p>
              </div>
            </div>
          </template>

          <template v-if="showComponentData.layout === 'top-2-bottom-2'">
            <div class="cube-style cube-style-top-2-bottom-2">
              <div
                class="cube-item"
                v-for="(item, index) in 4"
                :key="'top2bottom2-' + item"
                @click="handleClickIndex(index)"
                :class="{ active: clickDivIndex === index }"
              >
                <img
                  v-if="showComponentData.default_sub_list[index]"
                  :src="showComponentData.default_sub_list[index]"
                  class="itemImg"
                />
                <p class="tip" v-else>375x375像素或同等比例</p>
              </div>
            </div>
          </template>

          <template v-if="showComponentData.layout === 'top-2-bottom-3'">
            <div class="cube-style cube-style-top-2-bottom-3">
              <!-- 上面两格 -->
              <div class="cube-row top-row">
                <div
                  class="cube-item"
                  :key="'top-1'"
                  @click="handleClickIndex(0)"
                  :class="{ active: clickDivIndex === 0 }"
                >
                  <img
                    v-if="showComponentData.default_sub_list[0]"
                    :src="showComponentData.default_sub_list[0]"
                    class="itemImg"
                  />
                  <p class="tip" v-else>375x375像素或同等比例</p>
                </div>
                <div
                  class="cube-item"
                  :key="'top-2'"
                  @click="handleClickIndex(1)"
                  :class="{ active: clickDivIndex === 1 }"
                >
                  <img
                    v-if="showComponentData.default_sub_list[1]"
                    :src="showComponentData.default_sub_list[1]"
                    class="itemImg"
                  />
                  <p class="tip" v-else>375x375像素或同等比例</p>
                </div>
              </div>

              <!-- 下面三格 -->
              <div class="cube-row bottom-row">
                <div
                  class="cube-item"
                  @click="handleClickIndex(2)"
                  :class="{ active: clickDivIndex === 2 }"
                  :key="'bottom-1'"
                >
                  <img
                    v-if="showComponentData.default_sub_list[2]"
                    :src="showComponentData.default_sub_list[2]"
                    class="itemImg"
                  />
                  <p class="tip" v-else style="padding: 0 20px">180x375像素或同等比例</p>
                </div>
                <div
                  class="cube-item"
                  :key="'bottom-2'"
                  @click="handleClickIndex(3)"
                  :class="{ active: clickDivIndex === 3 }"
                >
                  <img
                    v-if="showComponentData.default_sub_list[3]"
                    :src="showComponentData.default_sub_list[3]"
                    class="itemImg"
                  />
                  <p class="tip" v-else style="padding: 0 20px">180x375像素或同等比例</p>
                </div>
                <div
                  class="cube-item"
                  :key="'bottom-3'"
                  @click="handleClickIndex(4)"
                  :class="{ active: clickDivIndex === 4 }"
                >
                  <img
                    v-if="showComponentData.default_sub_list[4]"
                    :src="showComponentData.default_sub_list[4]"
                    class="itemImg"
                  />
                  <p class="tip" v-else style="padding: 0 20px">180x375像素或同等比例</p>
                </div>
              </div>
            </div>
          </template>
        </div>

        <div class="upload-img">
          <div class="avatar-uploader" @click="handleChangeImage">
            <el-image
              v-if="showComponentData.default_sub_list[clickDivIndex]"
              :src="showComponentData.default_sub_list[clickDivIndex]"
              class="avatar"
              fit="contain"
            ></el-image>
            <i v-else class="el-icon-plus avatar-uploader-icon"
              ><el-icon> <Plus /> </el-icon
            ></i>
            <div v-if="showComponentData.default_sub_list[clickDivIndex]" class="mask">替换</div>
            <el-icon
              v-if="showComponentData.default_sub_list[clickDivIndex]"
              class="del-image"
              :size="20"
              @click.stop="handleDelImg"
              ><CircleCloseFilled
            /></el-icon>
          </div>
          <div class="link-text">
            <div class="link">
              <el-link type="primary" @click="showLinkDataDialog = true">请选择跳转链接</el-link>
            </div>
            <p class="tip">建议图片宽度375px，高度跟随第一张图片的高度变化</p>
          </div>
        </div>

        <!--        <el-form-item label="图片：">-->
        <!--          <div class="avatar-uploader" @click="handleChangeImage">-->
        <!--            <el-image-->
        <!--              v-if="showComponentData.default_sub_list[clickDivIndex]"-->
        <!--              :src="showComponentData.default_sub_list[clickDivIndex]"-->
        <!--              class="avatar"-->
        <!--              fit="contain"-->
        <!--            ></el-image>-->
        <!--            <i v-else class="el-icon-plus avatar-uploader-icon"-->
        <!--              ><el-icon> <Plus /> </el-icon-->
        <!--            ></i>-->
        <!--            <div v-if="showComponentData.default_sub_list[clickDivIndex]" class="mask">替换</div>-->
        <!--            <el-icon-->
        <!--              v-if="showComponentData.default_sub_list[clickDivIndex]"-->
        <!--              class="del-image"-->
        <!--              :size="20"-->
        <!--              @click.stop="handleDelImg"-->
        <!--              ><CircleCloseFilled-->
        <!--            /></el-icon>-->
        <!--          </div>-->
        <!--        </el-form-item>-->

        <!--        <el-form-item label="跳转链接：" v-if="showComponentData.show_more">-->
        <!--          <el-link type="primary" @click="showLinkDataDialog = true">请选择跳转链接</el-link>-->
        <!--        </el-form-item>-->
      </el-form>
    </div>

    <div class="component-style">
      <common-style
        :content-data="showComponentData"
        @update-style="handleUpdateStyle"
      ></common-style>
    </div>

    <link-list-dialog
      v-if="showLinkDataDialog"
      :show-link-dialog="showLinkDataDialog"
      @close-dialog="showLinkDataDialog = false"
    ></link-list-dialog>

    <image-selected-dialog
      v-if="showImageChooseDialog"
      :single-type="selectImageSingle"
      :operation-type="false"
      :show-image-choose-dialog="showImageChooseDialog"
      @close-dialog="handleCloseImageDialog"
    ></image-selected-dialog>
  </div>
</template>

<script setup lang="ts">
  import CommonStyle from '@/views/decoration/diyComponents/CommonStyleComponent/CommonStyle.vue'
  import debounce from 'lodash/debounce'
  import LinkListDialog from '@/views/decoration/diyComponents/LinkListDialog.vue'
  import { CircleCloseFilled, Plus } from '@element-plus/icons-vue'
  import { ElMessage } from 'element-plus'
  import ImageSelectedDialog from '@/views/decoration/diyComponents/ImageSelectedDialog.vue'

  const props = defineProps({
    contentData: {
      type: Object,
      default() {
        return {}
      }
    }
  })

  const form = reactive({
    itemStyle: {
      fontSize: 24,
      color: '#000000',
      fontWeight: 600,
      height: 100,
      textAlign: 'left',
      more_color: '#999'
    }
  })

  const showLinkDataDialog = ref(false)
  const showImageChooseDialog = ref(false)
  const selectImageSingle = ref(false)
  const clickDivIndex = ref<any>(0)
  const showComponentData = ref(props.contentData)

  watch(
    form,
    () => {
      emitFormUpdate()
    },
    { deep: true }
  )

  watch(
    () => showComponentData.value.layout,
    () => {
      clickDivIndex.value = 0
    }
  )

  const emitFormUpdate = debounce(() => {
    const raw = toRaw(form)
    showComponentData.value.itemStyle = raw.itemStyle
    handleUpdateComponent()
  }, 300)

  const emit = defineEmits(['updateData'])

  function handleUpdateComponent() {
    emit('updateData', showComponentData.value)
  }

  function handleUpdateStyle(val: any) {
    showComponentData.value.style = val
    handleUpdateComponent()
  }

  function handleClickIndex(index: number) {
    clickDivIndex.value = index
  }

  function handleChangeImage() {
    selectImageSingle.value = true
    showImageChooseDialog.value = true
  }

  function handleDelImg() {
    showComponentData.value.default_sub_list.splice(clickDivIndex.value, 1)
    handleUpdateComponent()
  }

  function handleCloseImageDialog(value: any) {
    if (value) {
      showComponentData.value.default_sub_list[clickDivIndex.value] = value.fileUrl
      handleUpdateComponent()
    }
    showImageChooseDialog.value = false
  }

  onMounted(() => {
    if (showComponentData.value.itemStyle) {
      form.itemStyle.fontSize = showComponentData.value.itemStyle.fontSize
      form.itemStyle.color = showComponentData.value.itemStyle.color
      form.itemStyle.fontWeight = showComponentData.value.itemStyle.fontWeight
      form.itemStyle.height = showComponentData.value.itemStyle.height
      form.itemStyle.textAlign = showComponentData.value.itemStyle.textAlign
      form.itemStyle.more_color = showComponentData.value.itemStyle.more_color
    }
  })
</script>

<style scoped lang="scss">
  .style-page {
    padding: 20px;

    .head-page-title {
      padding-top: 10px;
      padding-bottom: 20px;
      font-size: 18px;
      font-weight: bold;
      color: black;
    }

    .head-title {
      padding: 20px 0;
      font-size: 14px;
      font-weight: bold;
      color: black;
    }

    .line {
      width: 100%;
      height: 1px;
      background: #f5f7fa;
    }

    .add-area {
      width: 100%;

      .add-title {
        font-size: 14px;
        color: black;
        font-weight: bold;
        margin-bottom: 20px;
      }

      .content {
        .carousel-item {
          width: 100%;
          margin-bottom: 20px;
          position: relative;
          display: flex;
          flex-direction: column;
          background-color: #f7f8fa;
          padding: 10px;
          box-sizing: border-box;

          &:hover {
            .del-icon {
              display: block;
            }
          }

          .video-title {
            margin-bottom: 20px;
          }

          .video-content {
            width: 100%;
            position: relative;

            .video-thumb {
              width: 100%;
              height: 200px;
              background-color: #fff;
            }

            .mask {
              position: absolute;
              bottom: 0;
              left: 0;
              width: 100%;
              height: 30px;
              background-color: rgba(0, 0, 0, 0.4);
              display: flex;
              align-items: center;
              justify-content: center;
              opacity: 0;
              transition: opacity 0.3s ease;

              .opera {
                .upload-text {
                  color: #fff;
                  font-size: 14px;
                  margin-right: 10px;
                  cursor: pointer;
                }
              }
            }

            &:hover .mask {
              opacity: 1;
            }
          }

          .link-area {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 20px;
            font-size: 14px;
          }

          .link {
            width: 80%;
            display: flex;
            align-items: center;
            height: 40px;
            padding-left: 10px;
            background-color: #fff;
          }

          .del-icon {
            display: none;
            position: absolute;
            top: -2px;
            right: -2px;
            cursor: pointer;
            color: #8c939d;
          }
        }
      }
    }

    .component-style {
      width: 100%;
      box-sizing: border-box;
      margin-top: 20px;

      .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;

        .title {
          font-size: 16px;
          font-weight: bold;
        }
      }

      .flex {
        display: flex;
        justify-content: space-between;
        width: 100%;
        padding: 0 3px;
      }

      .cube-template {
        width: 350px;
        height: 350px;
        overflow: hidden;
        margin: 0 auto;
        padding: 10px;
      }
    }

    //.cube-style {
    //  aspect-ratio: 1 / 1;
    //}

    .cube-style-left-1-right-2,
    .cube-style-left-2-right-1,
    .cube-style-top-1-bottom-2,
    .cube-style-top-2-bottom-1,
    .cube-style-top-2-bottom-2,
    .cube-style-top-2-bottom-3 {
      aspect-ratio: 1 / 1;
    }

    .cube-style-row-2 {
      display: grid;
      //gap: 8px;
      grid-template-columns: repeat(2, 1fr);

      .cube-item {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #333;
        border: 1px solid #f4f5f8;
        cursor: pointer;
        width: 100%;
        min-height: 100px;
        //background-color: #999;
        //border-radius: 6px;
      }

      .cube-item.active {
        border: 1px solid var(--el-color-primary);
        background-color: #effbec;
      }
    }

    .cube-style-row-3 {
      display: grid;
      //gap: 8px;
      grid-template-columns: repeat(3, 1fr);
      .cube-item {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #333;
        border: 1px solid #f4f5f8;
        width: 100%;
        cursor: pointer;
        min-height: 133px;
      }

      .cube-item.active {
        border: 1px solid var(--el-color-primary);
        background-color: #effbec;
      }
    }

    .cube-style-top-2-bottom-2 {
      display: grid;
      //gap: 8px;
      grid-template-columns: repeat(2, 1fr);
      grid-template-rows: repeat(2, 1fr);

      .cube-item {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #333;
        border: 1px solid #f4f5f8;
        width: 100%;
        height: 100%;
        cursor: pointer;
        overflow: hidden;
        //background-color: #999;
        //border-radius: 6px;
      }

      .cube-item.active {
        border: 1px solid var(--el-color-primary);
        background-color: #effbec;
      }
    }

    .cube-style-left-1-right-2 {
      display: grid;
      aspect-ratio: 1 / 1;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: 1fr 1fr;
      //gap: 8px;
      width: 100%;

      .left {
        grid-row: span 2;
      }

      .cube-item {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        overflow: hidden;
        //background-color: #999;
        cursor: pointer;
        border: 1px solid #f4f5f8;
        //border-radius: 6px;
      }

      .cube-item.active {
        border: 1px solid var(--el-color-primary);
        background-color: #effbec !important;
      }
    }

    .cube-style-top-1-bottom-2 {
      display: grid;
      grid-template-rows: 1fr 1fr;
      grid-template-columns: repeat(2, 1fr);
      //gap: 8px;
      aspect-ratio: 1 / 1;

      .top {
        grid-column: span 2;
      }

      .cube-item {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #333;
        border: 1px solid #f4f5f8;
        overflow: hidden;
        cursor: pointer;
        //border-radius: 6px;
      }

      .cube-item.active {
        border: 1px solid var(--el-color-primary);
        background-color: #effbec !important;
      }
    }

    .cube-style-left-2-right-1 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      grid-template-rows: 1fr 1fr;
      aspect-ratio: 1 / 1;

      // 右侧的大块
      .right {
        grid-column: 2 / 3;
        grid-row: 1 / 3; // ✅ 跨两行
      }

      .left-top {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
      }

      .left-bottom {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
      }

      .cube-item {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #333;
        border: 1px solid #f4f5f8;
        overflow: hidden;
        cursor: pointer;
      }

      .cube-item.active {
        background-color: #effbec !important;
      }
    }

    .cube-style-top-2-bottom-1 {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      grid-template-rows: 1fr 1fr;
      //gap: 8px;
      aspect-ratio: 1 / 1;

      .bottom {
        grid-column: span 2;
      }

      .cube-item {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #333;
        border: 1px solid #f4f5f8;
        overflow: hidden;
        cursor: pointer;
        //border-radius: 6px;
      }
      .cube-item.active {
        border: 1px solid var(--el-color-primary);
        background-color: #effbec !important;
      }
    }

    .cube-style-top-2-bottom-3 {
      display: grid;
      grid-template-rows: 1fr 1fr;
      //gap: 6px;
      width: 100%;

      .top-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        //gap: 6px;
      }

      .bottom-row {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        //gap: 6px;
      }

      .cube-item {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        color: #333;
        border: 1px solid #f4f5f8;
        overflow: hidden;
        //border-radius: 6px;
        cursor: pointer;
      }

      .cube-item.active {
        border: 1px solid var(--el-color-primary);
        background-color: #effbec !important;
      }
    }

    .itemImg {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  .upload-img {
    margin-top: 10px;
    display: flex;
    background-color: #f7f8fa;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 8px;

    .avatar-uploader {
      border: 1px dashed #d9d9d9;
      border-radius: 12px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      width: 80px;
      height: 80px;
      background-color: #fff;
      text-align: center;

      .avatar {
        width: 80px;
        height: 80px;
        object-fit: cover;
      }

      .avatar-uploader-icon {
        width: 100%;
        height: 80px;
        line-height: 80px;
        text-align: center;
        font-size: 28px;
        color: #aaa;
      }

      .mask {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 30px;
        background-color: rgba(0, 0, 0, 0.6);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.3s ease;
        color: #fff;
        font-size: 12px;
      }

      .del-image {
        display: none;
        position: absolute;
        top: 0;
        right: 0;
        cursor: pointer;
        color: #8c939d;
      }

      &:hover .mask {
        opacity: 1;
      }

      &:hover .del-image {
        display: block;
      }
    }

    .link-text {
      padding-left: 10px;

      .link {
        display: flex;
        align-items: center;
        height: 40px;
        border-radius: 6px;
        background-color: #fff;
        padding-left: 10px;
        margin-bottom: 10px;
      }

      .tip {
        font-size: 12px;
      }
    }
  }
</style>
